<button class="layui-btn layui-btn-sm" onclick="slave_${object.code}_add()">
	<i class="layui-icon layui-icon-add-1"></i> ${button.name!'新增'}
</button>
<script type="text/javascript">
    var slave_${object.code}_add = function () {
    	
		var ID = '${gridId}';
		var PID = '${parentId}';
		
		// 必须选择父表
		if (isSelected(PID)) {
			// ------------------------------级联
	        var ref = '';
	       	// 主对象关联字段
	        var objectField = '${config.objectField!}';
	        // 子对象关联字段
	        var field = '${field!}';
	    	if(parent && objectField != '' && field != ''){
	    		// 从父组件上获取选中外键值
	    		var val = getSelectVal(PID, objectField);
	    		ref = ref + "?ref=" + field + ":" + val;
	    	}
	    	// ------------------------------级联
	    	
	    	var url = '/form/add/${object.code}' + ref;
	    	var width = ${menu.config.params.width!'720'};
	    	var height = ${menu.config.params.height!'undefined'};
	        dialog(ID, '${I18N(button.name)} ${object.name}', url , width, height);
		}
    	
    };
</script>